﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;

namespace 撤销恢复操作
{
    class Class1
    {

       public static void stop()
        {
            Process[] pro = Process.GetProcesses();
            for (int k = 0; k < pro.Length; k++)
            {
                if (pro[k].ProcessName.Equals("EXCEL.EXE"))
                {
                    try
                    {
                        pro[k].Kill();
                    }
                    catch
                    {
                        Console.WriteLine ("关闭进程时出错！");
                    }
                }
                if (pro[k].ProcessName.Equals("ctfmon.exe"))
                {
                    try
                    {
                        pro[k].Kill();
                    }
                    catch
                    {
                        Console.WriteLine("关闭进程时出错！");
                    }
                }
            }
        }
    }
}
